<include file="_header" />
<script>
	var photo_preview = '1';
</script>
<script src="../Public/js/preview.js" type="text/javascript"></script>
<script>
function getChecked() {
    var ids = new Array();
    $.each($('table input:checked'), function(i, n){
        ids.push( $(n).val() );
    });
    return ids;
}

function checkon(o){
    if( o.checked == true ){
        $(o).parents('tr').addClass('bg_on') ;
    }else{
        $(o).parents('tr').removeClass('bg_on') ;
    }
}

function checkAll(o){
    if( o.checked == true ){
        $('input[name="checkbox"]').attr('checked','true');
        $('tr[overstyle="on"]').addClass("bg_on");
    }else{
        $('input[name="checkbox"]').removeAttr('checked');
        $('tr[overstyle="on"]').removeClass("bg_on");
    }
}

//搜索用户
var isSearchHidden = <neq name="isSearch" value="1">1<else/>0</neq>;
function searchPhoto() {
    if(isSearchHidden == 1) {
        $("#searchPhoto_div").slideDown("fast");
        $(".searchPhoto_action").html("搜索完毕");
        isSearchHidden = 0;
    }else {
        $("#searchPhoto_div").slideUp("fast");
        $(".searchPhoto_action").html("搜索图片");
        isSearchHidden = 1;
    }
}

var ctrl = function(){
}
ctrl.prototype = {
	del:function(id){
		var id = id ? id : getChecked();
		id = id.toString();
		if(id=='' || id==0) return ;
		if( confirm("是否删除图片？") ){
		  $.post( '__URL__&act=delete_photo',{id:id},function(text ){
			  if( text == 1 ){
				  ui.success( "删除多张图片成功" );
				  var id_list = id.split( ',' );   
				  for (var j=0 ; j< id_list.length ; j++   ){
					  $('#list_'+id_list[j]).remove(); 
				  }
			  }else if( text == 2 ){
				  ui.success( "删除成功" );
				  $('#list_'+id).remove();
			  }else{
				  ui.error( "删除失败" );
			  }
		  });
		}
	}
}
var c = null;
</script>
<div class="so_main">
  <include file="_tab" />

    <div id="searchPhoto_div" <neq name="isSearch" value="1">style="display:none;"</neq>>
    <div class="page_tit">搜索{$ts['app']['app_alias']} [ <a href="javascript:void(0);" onclick="searchPhoto();">隐藏</a> ]</div>
    <div class="form2">
    <form action="__URL__&act=photo_list" method="post">
    <input type="hidden" name="isSearch" value="1"/>
        <php>if($isSearch != '1') $uid = '';</php>
        <dl class="lineD">
          <dt>用户ID：</dt>
          <dd>
            <input name="userId" class="txt" value="{$userId}">
          </dd>
        </dl>
	    <dl class="lineD">
          <dt>图片ID：</dt>
          <dd>
            <input name="id" class="txt" value="{$id}">
          </dd>
        </dl>
	    <dl class="lineD">
          <dt>{$ts['app']['app_alias']}ID：</dt>
          <dd>
            <input name="albumId" class="txt" value="{$albumId}">
          </dd>
        </dl>
	    <dl class="lineD">
          <dt>图片标题：</dt>
          <dd>
            <input name="name" class="txt" value="{$name}"/><span> 支持模糊查询。</span>
          </dd>
        </dl>
	    <dl class="">
          <dt>结果排序：</dt>
          <dd>
            <select name="order">
			  <option value = "desc" <eq name="order" value="desc">selected</eq>>降序排列，新的在前</option>
			  <option value = "asc" <eq name="order" value="asc">selected</eq>>升序排列，旧的在前</option>
			</select>
			<select name="limit">
			  <option value = "20" <eq name="limit" value="20">selected</eq>>每页显示20条</option>
			  <option value = "50" <eq name="limit" value="50">selected</eq>>每页显示50条</option>
			  <option value = "100" <eq name="limit" value="100">selected</eq>>每页显示100条</option>
			</select>
          </dd>
        </dl>
        <div class="page_btm">
	      <input type="submit" class="btn_b" value="确定" />
	    </div>
    </form>
    </div>
    </div>    
    <div class="Toolbar_inbox">
        <div class="page right">{$html}</div>
        <a href="javascript:void(0);" class="btn_a" onclick="searchPhoto();">
            <span class="searchPhoto_action"><neq name="isSearch" value="1">搜索图片<else/>搜索完毕</neq></span>
        </a>
        <a href="javascript:void(0);" class="btn_a" onclick="c.del()"><span>删除图片</span></a>
    </div>

	<div class="list">
        <table id="photo_list" width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
		    <th style="width:30px;">
		      <input type="checkbox" id="checkbox_handle" onclick="checkAll(this)" value="0">
		      <label for="checkbox"></label>
		    </th>
            <th>ID</th>
            <th>图片预览</th>
            <th>图片名称</th>
            <th>所属{$ts['app']['app_alias']}</th>
            <th>所属用户</th>
            <th>上传时间</th>
            <th>文件大小</th>
            <th>文件隐私</th>
            <th>操作</th>
          </tr>
          <volist name="data" id='vo'>
          <tr id="list_{$vo.id}">
            <td><input type="checkbox" name="checkbox" id="checkbox2" onclick="checkon(this)" value="{$vo.id}"></td>
            <a rel="__ROOT__/thumb.php?w=400&h=400&t=f&url={$vo.savepath|get_photo_url}" class="preview" title="{$vo.name}">
            <td>{$vo.id}</td>
            <td><a href="{:U('/Index/photo',array(id=>$vo['id'],aid=>$vo['albumId'],uid=>$vo['userId']))}#show_pic" title="{$vo.name}" target="_blank"><img src="__ROOT__/thumb.php?w=30&h=25&t=f&url={$vo.savepath|get_photo_url}" /></a></td>
            <td><a href="{:U('/Index/photo',array(id=>$vo['id'],aid=>$vo['albumId'],uid=>$vo['userId']))}#show_pic" target="_blank">{$vo.name}</a></td>
            </a>
            <td><a href="__URL__&act=album_list&id={$vo.albumId}">{$albumNames[$vo['albumId']]}</a></td>
            <td><space uid="vo.userId" >{uname}</space>{$vo.userId|getUserGroupIcon}</td>
            <td>{$vo.cTime|date="Y-m-d H:i:s",###}</td>
            <td>{$vo.size}</td>
            <td>{$vo.privacy|get_privacy}</td>
            <td>
			  <a href="javascript:void(0);" onclick="c.del({$vo['id']})">删除</a>
			</td>
          </tr>
          </volist>
        </table>
    </div>
    
    <div class="Toolbar_inbox">
        <div class="page right">{$html}</div>
        <a href="javascript:void(0);" class="btn_a" onclick="searchPhoto();">
            <span class="searchPhoto_action"><neq name="isSearch" value="1">搜索图片<else/>搜索完毕</neq></span>
        </a>
        <a href="javascript:void(0);" class="btn_a" onclick="c.del()"><span>删除图片</span></a>
    </div>
</div>
<script type="text/javascript">
var c = new ctrl();
</script>
<include file="_footer" />